/**
 * Created by zycool on 2016/11/1.
 * 专门建立此文件来处理维修记录详情展示
 */


var recordContent = {
    head: '',
    START_NODE: '',
    CORROSION_ENVIRONMENT_NODE: '',
    COAT_SURVEY_NODE: '',
    SURFACE_TREATMENT_NODE: '',
    CP_SURVEY_NODE: '',
    DEFECT_MEASURE_NODE: '',
    REPAIR_NODE: '',
    HG_REPAIR_NODE: '',
    COAT_REPAIR_NODE: '',
    END_NODE: '',
    body: ''
};


/** 缺陷点维修记录 10 大节点 - start **/
// 管沟开挖 - 1
var START_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'buriedDepth', title: '埋深(m)：'},
    {
        name: 'group', title: '开挖尺寸：', node: [
        {name: 'length', title: '长(m) '},
        {name: 'width', title: '宽(m) '},
        {name: 'depth', title: '深(m) '}
    ]
    },
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];

// 腐蚀环境调查 - 2
var CORROSION_ENVIRONMENT_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'deepRootedPlants', title: '根系植物：'},
    {name: 'groundwater', title: '地下水：'},
    {name: 'soilColor', title: '土壤颜色：'},
    {name: 'soilCompactness', title: '土壤松紧度：'},
    {name: 'soilHumidity', title: '土壤干湿度：'},
    {name: 'soilLayer', title: '土壤分层描述：'},
    {name: 'soilParticlesGroup', title: '土壤颗粒组划分：'},
    {name: 'soilPh', title: 'PH值：'},
    {name: 'soilResistivity', title: '土壤电阻率：'},
    {name: 'soilSamplingNumber', title: '土壤取样编号：'},
    {name: 'terrainGeomorphology', title: '地形地貌描述：'},
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];

// 防腐层调查 - 3
var COAT_SURVEY_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'appearance', title: '外观质量：'},
    {name: 'coatingMaterial', title: '防腐层类型：'},
    {name: 'peelingStrengthTest1', title: '剥离强度(N/cm)-测试1：'},
    {name: 'peelingStrengthTest2', title: '剥离强度(N/cm)-测试2：'},
    {name: 'peelingStrengthTest3', title: '剥离强度(N/cm)-测试3：'},
    {name: 'peelingStrengthTest4', title: '剥离强度(N/cm)-测试4：'},
    {name: 'electricSparkAmount', title: '电火花检测-漏点数(个)：'},
    {name: 'electricSparkTestVoltage', title: '电火花检测-检查电压(KV)：'},
    {name: 'isPipeReplacement', title: '是否需要换管：'},
    {name: 'coatingThicknessTest1', title: '厚度(mm)-测试1：'},
    {name: 'coatingThicknessTest2', title: '厚度(mm)-测试2：'},
    {name: 'coatingThicknessTest3', title: '厚度(mm)-测试3：'},
    {name: 'coatingThicknessTest4', title: '厚度(mm)-测试4：'},
    {name: 'pipeBodyTemperature', title: '管体温度(℃)：'},
    {name: 'redoxPotential', title: '氧化还原电位(-mV)：'},
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];

// 表面处理 - 4
var SURFACE_TREATMENT_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'anchorDepth', title: '锚纹深度(mm)：'},
    {name: 'derustingGrade', title: '除锈等级：'},
    {name: 'isPipeReplacement', title: '是否需要换管：'},
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];

// 阴保调查 - 5
var CP_SURVEY_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'acPotential', title: '交流干扰电压(V)：'},
    {name: 'freeCorrosionPotential', title: '自然电位(-mV)：'},
    {name: 'maxPotential', title: '直流干扰-最大值(mV)：'},
    {name: 'minPotential', title: '直流干扰-最小值(mV)：'},
    {name: 'onPotential', title: '通电电位(-mV)：'},
    {name: 'polarizedPotential', title: '极化电位(-mV)：'},
    {name: 'soilResistivity', title: '土壤电阻率：'},
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];

// 缺陷测量 - 6
var DEFECT_MEASURE_NODE = {
    /* 金属损失 */
    TDF_FEATURE_TYPE_JSSS: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'mileage', title: '绝对距离(m)：'},
        {name: 'length', title: '长(mm)：'},
        {name: 'width', title: '宽(mm)：'},
        {name: 'depth', title: '深(mm)：'},
        {name: 'maxDepth', title: '峰值深度(%wt)：'},
        {name: 'clock', title: '时钟位置(h:min)：'},
        {name: 'actualLength', title: '实测 长(mm)：'},
        {name: 'actualWidth', title: '实测 宽(mm)：'},
        {name: 'actualDepth', title: '实测 深(mm)：'},
        {name: 'actualMaxdepth', title: '实测 峰值深度(%wt)：'},
        {name: 'actualClock', title: '实测 时钟位置(h:min)：'},
        {name: 'defectNumber', title: '缺陷编号：'},
        {name: 'featureSubType', title: '缺陷类型：'},
        {name: 'actualFeatureType', title: '实测缺陷类型：'},
        {name: 'actualX', title: '实测经度(°)：'},
        {name: 'actualY', title: '实测纬度(°)：'},
        {name: 'actualZ', title: '实测高度(°)：'},
        {name: 'planRepairMethod', title: '评价修复方法：'},
        {name: 'repairMethod', title: '变更修复方法：'},
        {name: 'repairWorkload', title: '工作量(㎡)：'},
        {name: 'repairRemark', title: '变更修复方法原因：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 凹陷 */
    TDF_FEATURE_TYPE_AX: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'mileage', title: '绝对距离(m)：'},
        {name: 'length', title: '长(mm)：'},
        {name: 'width', title: '宽(mm)：'},
        {name: 'depth', title: '深(mm)：'},
        {name: 'maxDepth', title: '峰值深度(%wt)：'},
        {name: 'clock', title: '时钟位置(h:min)：'},
        {name: 'actualLength', title: '实测 长(mm)：'},
        {name: 'actualWidth', title: '实测 宽(mm)：'},
        {name: 'actualDepth', title: '实测 深(mm)：'},
        {name: 'actualMaxdepth', title: '实测 峰值深度(%wt)：'},
        {name: 'actualClock', title: '实测 时钟位置(h:min)：'},
        {name: 'defectNumber', title: '缺陷编号：'},
        {name: 'featureSubType', title: '缺陷类型：'},
        {name: 'actualFeatureType', title: '实测缺陷类型：'},
        {name: 'actualX', title: '实测经度(°)：'},
        {name: 'actualY', title: '实测纬度(°)：'},
        {name: 'actualZ', title: '实测高度(°)：'},
        {name: 'planRepairMethod', title: '评价修复方法：'},
        {name: 'repairMethod', title: '变更修复方法：'},
        {name: 'repairWorkload', title: '工作量(㎡)：'},
        {name: 'repairRemark', title: '变更修复方法原因：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 焊缝异常 */
    TDF_FEATURE_TYPE_HFYC: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'mileage', title: '绝对距离(m)：'},
        {name: 'length', title: '长(mm)：'},
        {name: 'width', title: '宽(mm)：'},
        {name: 'maxDepth', title: '峰值深度(%wt)：'},
        {name: 'clock', title: '时钟位置(h:min)：'},
        {name: 'actualLength', title: '实测 长(mm)：'},
        {name: 'actualWidth', title: '实测 宽(mm)：'},
        {name: 'actualClock', title: '实测 时钟位置(h:min)：'},
        {name: 'defectDescription', title: '实测 缺陷描述：'},
        {name: 'ndtReportNumber', title: '无损检测报告编号：'},
        {name: 'defectNumber', title: '缺陷编号：'},
        {name: 'featureSubType', title: '缺陷类型：'},
        {name: 'actualFeatureType', title: '实测缺陷类型：'},
        {name: 'actualX', title: '实测经度(°)：'},
        {name: 'actualY', title: '实测纬度(°)：'},
        {name: 'actualZ', title: '实测高度(°)：'},
        {name: 'planRepairMethod', title: '评价修复方法：'},
        {name: 'repairMethod', title: '变更修复方法：'},
        {name: 'repairWorkload', title: '工作量(㎡)：'},
        {name: 'repairRemark', title: '变更修复方法原因：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 椭圆变形 */
    TDF_FEATURE_TYPE_TYBX: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'mileage', title: '绝对距离(m)：'},
        {name: 'maxDeformation', title: '缺陷信息(最大变形量%OD)：'},
        {name: 'length', title: '缺陷信息(长mm)：'},
        {name: 'actualMaxDeformation', title: '实测 缺陷信息(最大变形量%OD)：'},
        {name: 'actualLength', title: '实测 缺陷信息(长mm)：'},
        {name: 'defectNumber', title: '缺陷编号：'},
        {name: 'featureSubType', title: '缺陷类型：'},
        {name: 'actualFeatureType', title: '实测缺陷类型：'},
        {name: 'actualX', title: '实测经度(°)：'},
        {name: 'actualY', title: '实测纬度(°)：'},
        {name: 'actualZ', title: '实测高度(°)：'},
        {name: 'planRepairMethod', title: '评价修复方法：'},
        {name: 'repairMethod', title: '变更修复方法：'},
        {name: 'repairWorkload', title: '工作量(㎡)：'},
        {name: 'repairRemark', title: '变更修复方法原因：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 类裂纹 */
    TDF_FEATURE_TYPE_LLW: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'mileage', title: '绝对距离(m)：'},
        {name: 'length', title: '长(mm)：'},
        {name: 'width', title: '宽(mm)：'},
        {name: 'depth', title: '深(mm)：'},
        {name: 'maxDepth', title: '峰值深度(%wt)：'},
        {name: 'clock', title: '时钟位置(h:min)：'},
        {name: 'actualLength', title: '实测 长(mm)：'},
        {name: 'actualWidth', title: '实测 宽(mm)：'},
        {name: 'actualDepth', title: '实测 深(mm)：'},
        {name: 'actualMaxdepth', title: '实测 峰值深度(%wt)：'},
        {name: 'actualClock', title: '实测 时钟位置(h:min)：'},
        {name: 'ndtReportNumber', title: '无损检测报告编号：'},
        {name: 'defectDescription', title: '缺陷描述：'},
        {name: 'defectNumber', title: '缺陷编号：'},
        {name: 'featureSubType', title: '缺陷类型：'},
        {name: 'actualFeatureType', title: '实测缺陷类型：'},
        {name: 'actualX', title: '实测经度(°)：'},
        {name: 'actualY', title: '实测纬度(°)：'},
        {name: 'actualZ', title: '实测高度(°)：'},
        {name: 'planRepairMethod', title: '评价修复方法：'},
        {name: 'repairMethod', title: '变更修复方法：'},
        {name: 'repairWorkload', title: '工作量(㎡)：'},
        {name: 'repairRemark', title: '变更修复方法原因：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 损伤缺陷 */
    TDF_FEATURE_TYPE_SSQX: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'mileage', title: '绝对距离(m)：'},
        {name: 'length', title: '长(mm)：'},
        {name: 'width', title: '宽(mm)：'},
        {name: 'depth', title: '深(mm)：'},
        {name: 'maxDepth', title: '峰值深度(%wt)：'},
        {name: 'clock', title: '时钟位置(h:min)：'},
        {name: 'actualLength', title: '实测 长(mm)：'},
        {name: 'actualWidth', title: '实测 宽(mm)：'},
        {name: 'actualDepth', title: '实测 深(mm)：'},
        {name: 'actualMaxdepth', title: '实测 峰值深度(%wt)：'},
        {name: 'actualClock', title: '实测 时钟位置(h:min)：'},
        {name: 'defectNumber', title: '缺陷编号：'},
        {name: 'featureSubType', title: '缺陷类型：'},
        {name: 'actualFeatureType', title: '实测缺陷类型：'},
        {name: 'actualX', title: '实测经度(°)：'},
        {name: 'actualY', title: '实测纬度(°)：'},
        {name: 'actualZ', title: '实测高度(°)：'},
        {name: 'planRepairMethod', title: '评价修复方法：'},
        {name: 'repairMethod', title: '变更修复方法：'},
        {name: 'repairWorkload', title: '工作量(㎡)：'},
        {name: 'repairRemark', title: '变更修复方法原因：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 补丁信息 */
    TDF_FEATURE_TYPE_BDXX: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'mileage', title: '绝对距离(m)：'},
        {name: 'length', title: '长(mm)：'},
        {name: 'width', title: '宽(mm)：'},
        {name: 'clock', title: '时钟位置(h:min)：'},
        {name: 'actualLength', title: '实测 长(mm)：'},
        {name: 'actualWidth', title: '实测 宽(mm)：'},
        {name: 'actualClock', title: '实测 时钟位置(h:min)：'},
        {name: 'defectNumber', title: '缺陷编号：'},
        {name: 'featureSubType', title: '缺陷类型：'},
        {name: 'actualFeatureType', title: '实测缺陷类型：'},
        {name: 'actualX', title: '实测经度(°)：'},
        {name: 'actualY', title: '实测纬度(°)：'},
        {name: 'actualZ', title: '实测高度(°)：'},
        {name: 'planRepairMethod', title: '评价修复方法：'},
        {name: 'repairMethod', title: '变更修复方法：'},
        {name: 'repairWorkload', title: '工作量(㎡)：'},
        {name: 'repairRemark', title: '变更修复方法原因：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ]
};

// 缺陷修复 - 7
var REPAIR_NODE = {
    /* 复合材料补强修复 */
    PIC_TDF_REPAIR_COMPOSITES: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'repairMethod', title: '修复方法：'},
        {name: 'repairMaterial', title: '修复材料：'},
        {name: 'repairLength', title: '修复长度(mm)：'},
        {name: 'repairLayer', title: '修复层数：'},
        {name: 'surfaceTemperature', title:'管表温度(℃)：'},
        {name: 'environmentalTemperature', title:'环境温度(℃)：'},
        {name: 'solidificationTime', title: '固化时间(min)：'},
        {name: 'hardness', title: '巴氏硬度(HBa)：'},
        {name: 'materialManufacturer', title: '修复材料厂商：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 钢质环氧套筒补强修复 */
    PIC_TDF_REPAIR_EPOXY_SLEEVE: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'socketStructure', title: '套筒结构：'},
        {name: 'material', title: '管材：'},
        {name: 'wallThickness', title: '壁厚(mm)：'},
        {name: 'od', title: '外径(mm)：'},
        {name: 'repairLength', title: '修复长度(mm)：'},
        {name: 'environmentalTemperature', title:'环境温度(℃)：'},
        {name: 'surfaceTemperature', title:'管表温度(℃)：'},
        {name: 'solidificationTime', title: '固化时间(min)：'},
        {name: 'perfusionProcess', title: '灌注工艺：'},
        {name: 'workload', title: '工作量(㎡)：'},
        {name: 'manufacturer', title: '生产厂商：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* A和B型套筒补强修复 */
    PIC_TDF_REPAIR_ABTYPE_SLEEVE: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'wallThickness', title: '套筒壁厚(mm)：'},
        {name: 'length', title: '套筒长度(mm)：'},
        {name: 'material', title: '管材：'},
        {name: 'environmentalTemperature', title:'环境温度(℃)：'},
        {name: 'surfaceTemperature', title:'管表温度(℃)：'},
        {name: 'weldingGrade', title: '焊材牌号：'},
        {name: 'weldingMethod', title: '焊接方法：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 换管 */
    PIC_TDF_REPAIR_REPLACE_PIPE: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'startX', title: '起始位置x：'},
        {name: 'startY', title: '起始位置y：'},
        {name: 'startZ', title: '起始位置z：'},
        {name: 'endX', title: '终点位置x：'},
        {name: 'endY', title: '终点位置y：'},
        {name: 'endZ', title: '终点位置z：'},
        {name: 'startMileage', title: '起始绝对距离(m)：'},
        {name: 'endMileage', title: '终点绝对距离(m)：'},
        {name: 'material', title: '换管材质：'},
        {name: 'manuPipeType', title: '制管方式：'},
        {name: 'diameter', title: '管径(mm)：'},
        {name: 'wallThickness', title: '壁厚(mm)：'},
        {name: 'coatingMaterial', title: '防腐材料：'},
        {name: 'coatingGrade', title: '防腐等级：'},
        {name: 'wpsNumber', title: 'wps编号：'},
        {name: 'ndtType', title: '无损检测类型：'},
        {name: 'repairind', title: '是否返修：'},
        {name: 'testingCompany', title: '检测单位：'},
        {name: 'testDate', title: '检测日期：'},
        {name: 'weldingMaterial', title: '焊接材质：'},
        {name: 'weldingRemark', title: '焊接备注：'},
        {name: 'weldingImgList', title: '焊接图片：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ],
    /* 其他修复方法 */
    PIC_TDF_REPAIR_OTHER: [
        {name: 'isCompletion', title: '是否完成：'},
        {name: 'remark', title: '备注：'},
        {name: 'imgList', title: '照片：'}
    ]
};

// 防腐层修复 - 8
var COAT_REPAIR_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'edmLeak', title: '电火花检漏(电压KV)：'},
    {name: 'environmentalTemperature', title: '环境温度(℃)：'},
    {name: 'isJoint', title: '是否为补口：'},
    {name: 'materialManufacturer', title: '修复材料厂商：'},
    {name: 'repairLength', title: '修复长度(mm)：'},
    {name: 'repairMaterial', title: '修复材料：'},
    {name: 'repairThickness', title: '修复厚度(mm)：'},
    {name: 'surfaceTemperature', title: '管表温度(℃)：'},
    {name: 'workload', title: '工作量(㎡)：'},
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];

// 焊接 - 9
var HG_REPAIR_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'wpsNumber', title: 'wps编号：'},
    {name: 'ndtType', title: '无损检测类型：'},
    {name: 'repairind', title: '是否返修：'},
    {name: 'testingCompany', title: '检测单位：'},
    {name: 'testDate', title: '检测日期：'},
    {name: 'weldingMaterial', title: '焊接材质：'},
    {name: 'weldList', title: '焊缝信息', node: [
        {name: 'gwwNumber', title: '环焊缝编号：'},
        {name: 'x', title: 'X：'},
        {name: 'y', title: 'Y：'},
        {name: 'z', title: 'Z：'}
    ]},
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];

// 管沟回填 - 10
var END_NODE = [
    {name: 'isCompletion', title: '是否完成：'},
    {name: 'remark', title: '备注：'},
    {name: 'imgList', title: '照片：'}
];
/** 缺陷点维修记录 10 大节点 - end **/

function loopNodeProperty(data, node, type, title, number, length, id) {
    if (!data) {
        return false;
    }else{
        data = DyyBase.clearNull(data);
    }

    var head = '', body = '<p class="zy-dy-p-head">现场测量数据：</p>', imgarr = [];

    for (var i = 0, len = node.length; i < len; i++) {
        if (node[i]['name'] === 'isCompletion') {
            var cls = 'green';
            if (data.hasOwnProperty('isCompletion') && data['isCompletion'] == 0) {
                cls = 'gray';
            }
            if (number == length - 1) {
                head += '<p><span><i class="zy-num-click ' + cls + '" data-node="' + type + '" data-id="' + id + '">' + (++number) + '</i>' + title + '</span></p>';
            } else {
                head += '<p><span><i class="zy-num-click ' + cls + '" data-node="' + type + '" data-id="' + id + '">' + (++number) + '</i>' + title + '</span></p><p class="zy-dy-bg"></p>';
            }
        } else {
            if (node[i]['name'] === 'group') {
                var temp = '';
                for (var j = 0, lens = node[i]['node'].length; j < lens; j++) {
                    if (data.hasOwnProperty(node[i]['node'][j]['name'])) {
                        temp += ' ' +  node[i]['node'][j]['title'] + ' ' + data[node[i]['node'][j]['name']] + ' ';
                    }
                }
                body += '<p class="zy-dy-p-span" title="'+ node[i]['title'] + temp +'">' + node[i]['title'] + temp + '</p>';
            }else if(node[i]['name'] === 'weldList'){
                var weld = '', tick = 0;
                if(data.hasOwnProperty(node[i]['name'])){
                    if(data[node[i]['name']] && data[node[i]['name']].length){
                        for(var x = 0, len_x = data[node[i]['name']].length; x < len_x; x++){
                            tick = x + 1;
                            weld += '<p class="zy-dy-p-heads">'+node[i]['title']+'('+(tick)+')'+'：</p>';
                            for(var y = 0, len_y = node[i]['node'].length; y < len_y; y++){
                                weld += '<p class="zy-dy-p-spans">'+node[i]['node'][y]['title']+data[node[i]['name']][x][node[i]['node'][y]['name']]+'</p>';
                            }
                        }
                    }
                }
                body += weld;
            } else if (node[i]['name'] === 'imgList') {
                if (data.hasOwnProperty('imgList')) {
                    if (data['imgList']) {
                        if (data['imgList'].hasOwnProperty('ALL')) {
                            var imgs = '';
                            for (var n = 0, lenth = data['imgList']['ALL'].length; n < lenth; n++) {
                                imgs += '<span><a target="_blank" href="' + DyyBase.file_path + data['imgList']['ALL'][n]['path'] + '"><img class="list" src="' + DyyBase.file_path + data['imgList']['ALL'][n]['path'] + '"></a></span>';
                            }
                            if(imgs){
                                body += '<p class="zy-dy-p-head">现场照片：</p>';
                                body += '<p class="zy-imglist">' + imgs + '</p>';
                            }
                        }
                        if (data['imgList'].hasOwnProperty('REPAIR_BEFORE')) {
                            var before = '';
                            for (var a = 0, lena = data['imgList']['REPAIR_BEFORE'].length; a < lena; a++) {
                                before += '<span><a target="_blank" href="' + DyyBase.file_path + data['imgList']['REPAIR_BEFORE'][a]['path'] + '"><img src="' + DyyBase.file_path + data['imgList']['REPAIR_BEFORE'][a]['path'] + '"></a></span>';
                            }
                            if(before){
                                body += '<p class="zy-dy-p-head">修复前：</p><p class="zy-imglist">' + before + '</p>';
                            }
                        }
                        if (data['imgList'].hasOwnProperty('REPAIR_DURING')) {
                            var middle = '';
                            for (var b = 0, lenb = data['imgList']['REPAIR_DURING'].length; b < lenb; b++) {
                                middle += '<span><a target="_blank" href="' + DyyBase.file_path + data['imgList']['REPAIR_DURING'][b]['path'] + '"><img src="' + DyyBase.file_path + data['imgList']['REPAIR_DURING'][b]['path'] + '"></a></span>';
                            }
                            if(middle){
                                body += '<p class="zy-dy-p-head">修复中：</p><p class="zy-imglist">' + middle + '</p>';
                            }
                        }
                        if (data['imgList'].hasOwnProperty('REPAIR_AFTER')) {
                            var after = '';
                            for (var c = 0, lenc = data['imgList']['REPAIR_AFTER'].length; c < lenc; c++) {
                                after += '<span><a target="_blank" href="' + DyyBase.file_path + data['imgList']['REPAIR_AFTER'][c]['path'] + '"><img src="' + DyyBase.file_path + data['imgList']['REPAIR_AFTER'][c]['path'] + '"></a></span>';
                            }
                            if(after){
                                body += '<p class="zy-dy-p-head">修复后：</p><p class="zy-imglist">' + after + '</p>';
                            }
                        }
                        if (data['imgList'].hasOwnProperty('NDTTYPE')) {
                            var ndttype = '';
                            for (var d = 0, lend = data['imgList']['NDTTYPE'].length; d < lend; d++) {
                                ndttype += '<span><a target="_blank" href="' + DyyBase.file_path + data['imgList']['NDTTYPE'][d]['path'] + '"><img src="' + DyyBase.file_path + data['imgList']['NDTTYPE'][d]['path'] + '"></a></span>';
                            }
                            if(ndttype){
                                body += '<p class="zy-dy-p-head">无损检测照片：</p><p class="zy-imglist">' + ndttype + '</p>';
                            }
                        }
                        if (data['imgList'].hasOwnProperty('WELDWORKTYPE')) {
                            var work = '';
                            for (var e = 0, lene = data['imgList']['WELDWORKTYPE'].length; e < lene; e++) {
                                work += '<span><a target="_blank" href="' + DyyBase.file_path + data['imgList']['WELDWORKTYPE'][e]['path'] + '"><img src="' + DyyBase.file_path + data['imgList']['WELDWORKTYPE'][e]['path'] + '"></a></span>';
                            }
                            if(work){
                                body += '<p class="zy-dy-p-head">焊接作业指导书：</p><p class="zy-imglist">' + work + '</p>';
                            }
                        }
                    }
                }
            } else {
                if (data.hasOwnProperty(node[i]['name'])) {
                    if (node[i]['name'] == 'remark') {
                        body += '<p class="zy-dy-p-remark" title="'+ node[i]['title'] +  data[node[i]['name']] +'">' + node[i]['title'] + '<span>' + data[node[i]['name']] + '</span></p>';
                    } else {
                        body += '<p class="zy-dy-p-span" title="'+ node[i]['title'] + data[node[i]['name']] +'">' + node[i]['title'] + '<span>' + data[node[i]['name']] + '</span></p>';
                    }
                }
            }
        }
    }

    body = body + '<div class="clear"></div>';

    recordContent.head += head;

    if (!recordContent.body) {
        recordContent.body = body;
    }

    recordContent[type] = body;

    return imgarr;
}

function loopNodeData(data, id, code, tr, status, tag) {
    var $dy_tr = $('<tr class="zy-dy-tr" data-defectId-repair="' + id + '"><td colspan="12"><div class="zy-details-box"><div class="zy-dy-inner"></div></div></td></tr>');
    var $dy_box = $dy_tr.find('div.zy-dy-inner');
    var $repair_status = $('<div class="zy-dy-status"></div>');
    var $repair_body = $('<div class="zy-dy-info"></div>');
    var $repair_buttons = $('<div class="zy-work-repair-button"></div>');
    var temp_img_arr = [];

    // 全部完成标识
    var $all_done = '<div class="zy-work-repair-done"><i class="zy-repair-done-icon"></i><p>编号 ' + code + ' 的缺陷点已维修完成。</p></div>';
    // 收起按钮
    var $pick_btn = $('<button type="button" class="zy-button zy-pick-up" data-id="' + id + '"><i></i>收起</button>');
    $pick_btn.click(function () {
        $pick_btn.parents('tr.zy-dy-tr').hide();
        tag.removeClass('active');
    });
    // 作业点维修记录
    var $work_btn = $('<button class="zy-button-s zy-delete-s" type="button" data-id="' + id + '"><i class="zy-delete-icon"></i>作业点维修记录</button>');
    $work_btn.click(function () {
        window.location.href = DyyBase.root_path + '/pbf/defectRepairMgr/repairWorkRecord.html?id=' + id;
    });

    /** 主体 - start **/
    for (var i = 0, len = data.length; i < len; i++) {
        switch (true) {
            case (data[i].hasOwnProperty('START_NODE')):
                if(data[i]['START_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['START_NODE'], START_NODE, 'START_NODE', '管沟开挖', i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('CORROSION_ENVIRONMENT_NODE')):
                if(data[i]['CORROSION_ENVIRONMENT_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['CORROSION_ENVIRONMENT_NODE'], CORROSION_ENVIRONMENT_NODE, 'CORROSION_ENVIRONMENT_NODE', '腐蚀环境调查', i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('COAT_SURVEY_NODE')):
                if(data[i]['COAT_SURVEY_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['COAT_SURVEY_NODE'], COAT_SURVEY_NODE, 'COAT_SURVEY_NODE', '防腐层调查', i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('SURFACE_TREATMENT_NODE')):
                if(data[i]['SURFACE_TREATMENT_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['SURFACE_TREATMENT_NODE'], SURFACE_TREATMENT_NODE, 'SURFACE_TREATMENT_NODE', '表面处理', i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('CP_SURVEY_NODE')):
                if(data[i]['CP_SURVEY_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['CP_SURVEY_NODE'], CP_SURVEY_NODE, 'CP_SURVEY_NODE', '阴保调查', i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('DEFECT_MEASURE_NODE')):
                if(data[i]['DEFECT_MEASURE_NODE']){
                    console.log(data[i]['DEFECT_MEASURE_NODE']);
                    var gauge = '缺陷测量';
                    var gaugeType = {};
                    if(data[i]['DEFECT_MEASURE_NODE'].hasOwnProperty('featureTypeCode')){
                        switch (data[i]['DEFECT_MEASURE_NODE']['featureTypeCode']){
                            case 'TDF_FEATURE_TYPE_JSSS':
                                gaugeType = DEFECT_MEASURE_NODE['TDF_FEATURE_TYPE_JSSS'];
                                break;
                            case 'TDF_FEATURE_TYPE_AX':
                                gaugeType = DEFECT_MEASURE_NODE['TDF_FEATURE_TYPE_AX'];
                                break;
                            case 'TDF_FEATURE_TYPE_HFYC':
                                gaugeType = DEFECT_MEASURE_NODE['TDF_FEATURE_TYPE_HFYC'];
                                break;
                            case 'TDF_FEATURE_TYPE_TYBX':
                                gaugeType = DEFECT_MEASURE_NODE['TDF_FEATURE_TYPE_TYBX'];
                                break;
                            case 'TDF_FEATURE_TYPE_LLW':
                                gaugeType = DEFECT_MEASURE_NODE['TDF_FEATURE_TYPE_LLW'];
                                break;
                            case 'TDF_FEATURE_TYPE_SSQX':
                                gaugeType = DEFECT_MEASURE_NODE['TDF_FEATURE_TYPE_SSQX'];
                                break;
                            case 'TDF_FEATURE_TYPE_BDXX':
                                gaugeType = DEFECT_MEASURE_NODE['TDF_FEATURE_TYPE_BDXX'];
                                break;
                            default:
                                break;
                        }
                    }
                    temp_img_arr = loopNodeProperty(data[i]['DEFECT_MEASURE_NODE'], gaugeType, 'DEFECT_MEASURE_NODE', gauge, i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('REPAIR_NODE')):
                if(data[i]['REPAIR_NODE']){
                    var method = '缺陷修复';
                    var nodeType = {};
                    if(data[i]['REPAIR_NODE'].hasOwnProperty('repairMethodCode')){
                        method = data[i]['REPAIR_NODE']['nodeName'] ? data[i]['REPAIR_NODE']['nodeName'] : method;
                        switch (data[i]['REPAIR_NODE']['repairMethodCode']){
                            case 'PIC_TDF_REPAIR_COMPOSITES':
                                nodeType = REPAIR_NODE['PIC_TDF_REPAIR_COMPOSITES'];
                                break;
                            case 'PIC_TDF_REPAIR_EPOXY_SLEEVE':
                                nodeType = REPAIR_NODE['PIC_TDF_REPAIR_EPOXY_SLEEVE'];
                                break;
                            case 'PIC_TDF_REPAIR_ABTYPE_SLEEVE':
                                nodeType = REPAIR_NODE['PIC_TDF_REPAIR_ABTYPE_SLEEVE'];
                                break;
                            case 'PIC_TDF_REPAIR_REPLACE_PIPE':
                                nodeType = REPAIR_NODE['PIC_TDF_REPAIR_REPLACE_PIPE'];
                                break;
                            case 'PIC_TDF_REPAIR_OTHER':
                                nodeType = REPAIR_NODE['PIC_TDF_REPAIR_OTHER'];
                                break;
                            default:
                                break;
                        }
                    }
                    temp_img_arr = loopNodeProperty(data[i]['REPAIR_NODE'], nodeType, 'REPAIR_NODE', method, i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('HG_REPAIR_NODE')):
                if(data[i]['HG_REPAIR_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['HG_REPAIR_NODE'], HG_REPAIR_NODE, 'HG_REPAIR_NODE', '焊接', i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('COAT_REPAIR_NODE')):
                if(data[i]['COAT_REPAIR_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['COAT_REPAIR_NODE'], COAT_REPAIR_NODE, 'COAT_REPAIR_NODE', '防腐层修复', i, len, id);
                }
                break;
            case (data[i].hasOwnProperty('END_NODE')):
                if(data[i]['END_NODE']){
                    temp_img_arr = loopNodeProperty(data[i]['END_NODE'], END_NODE, 'END_NODE', '管沟回填', i, len, id);
                }
                break;
            default:
                break;
        }
    }
    /** 主体 - end **/

    $repair_status.html(recordContent.head);
    $repair_body.html(recordContent.body);
    $dy_box.append($repair_status);
    $dy_box.append($repair_body);

    // 追加完成标识和按钮
    $repair_buttons.append($pick_btn);
    if (status == 'ALREADY_REPAIR' || status == 'DIFFICULT_TO_REPAIR') {
        $dy_box.append($all_done);
        $repair_buttons.append($work_btn);
    }
    $repair_buttons.append('<div class="clear"></div>');

    // 追加到tr
    $dy_box.append($repair_buttons);
    tr.after($dy_tr);
}

function loopNode(data, id, number, tr, status, tag) {
    if (data) {
        if ($.isArray(data) && data.length > 0) {
            loopNodeData(data, id, number, tr, status, tag);
        } else {
            var $empty_tr = tr.siblings('tr[data-empty="' + id + '"]');
            if($empty_tr.length > 0){
                $empty_tr.show();
            }else{
                tr.after('<tr class="zy-dy-tr zy-dy-empty" data-empty="' + id + '"><td colspan="11"><div class="zy-datatable-empty"><p><img src="' + DyyBase.root_path + '/static/img/chart_no_data.png"></p><div class="zy-empty-footer"><button type="button" class="zy-button zy-pick-up zy-pick-empty"><i></i>收起</button></div></div></td></tr>');
            }
        }
    } else {
        $(this).MSG({
            type: 'error',
            content: '缺少必要的记录数据!'
        });
        return false;
    }
}



